import ajax from './ajax.js'
const BASE_URL = '/api'

// 登录
export const reqLogin = (username, password) => ajax(`${BASE_URL}/user/login`, {username, password}, 'POST')
// 注册
export const reqRegister = (username, password) => ajax(`${BASE_URL}/user/register`, {username, password}, 'POST')
// 退出登录
export const reqLogout = (id) => ajax(`${BASE_URL}/user/logout`, {id}, 'GET')
// 更改昵称
export const reqSetNickname = (userBO) => ajax(`${BASE_URL}/user/setNickname`, {userBO}, 'POST')

// 请求通讯录
export const reqContacts = (userId) => ajax(`${BASE_URL}/user/myFriendsWithSorted`, {userId}, 'GET')
// 搜索好友
export const reqSearchFris = (friendUsername) => ajax(`${BASE_URL}/user/searchWithoutCheck`, {friendUsername}, 'GET')
// 请求添加好友
export const reqAddToContacts = ({userId, friendUsername}) => ajax(`${BASE_URL}/user/addFriend`, {userId, friendUsername}, 'POST')
// 处理别人的请求好友消息
export const reqHandleFrisRequest = ({accepterId, senderId, type}) => ajax(`${BASE_URL}/user/checkFriendRequest`, {accepterId, senderId, type}, 'POST')
// 查询请求列表
export const reqGetFriendRequestList = (userId) => ajax(`${BASE_URL}/user/queryFriendRequests`, {userId}, 'GET')
